<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>修改比赛信息</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style>
        body {margin:0;}

        ul {
            list-style-type: none;
            margin: 0;
            padding: 0;
            overflow: hidden;
            background-color: #333;
            position: fixed;
            top: 0;
            width: 100%;
        }

        li {
            float: left;
        }

        li a {
            display: block;
            color: white;
            text-align: center;
            padding: 14px 16px;
            text-decoration: none;
        }

        li a:hover:not(.active) {
            background-color: #111;
        }

        .active {
            background-color: #4CAF50;
        }
    </style>
</head>
<body>

<ul>
    <li><a href="#">比赛管理员端口</a></li>
    <li><a href="/CompetitionOs">比赛管理</a></li>
    <li><a href="/PlayerOs">选手管理</a></li>
    <li><a href="/showScore">投票统计</a></li>
    <li><a href="/LoginOut">退出系统</a></li>
</ul>
<div style="padding:20px;margin-top:30px;background-color:#1abc9c;height:1500px;">
    <form class="container" style="width: 400px" method="post" th:action="@{/updateCompetition/admin}" onsubmit="return test(this)" >
        <h1>修改比赛信息</h1>
        <br>
        <div>
            ID:
            <input class="form-control" type="text" th:value="${competition.getComId()}" name="comId" aria-label="Disabled input example" style="width: 50px" readonly>
        </div>
        <br>
        比赛名称：<input type="text"  id="comName" th:value="${competition.getComName()}" class="form-control" name="comName">
        <br>
        <div>
            选手1
            <select class="form-select form-select-lg mb-3" id="playerId_1" name="playerId_1" aria-label=".form-select-lg example">
                <option th:value="${competition.getPlayerId_1().getPlayerId()}" th:text="${competition.getPlayerId_1().getPlayerName()}"></option>
                <option th:each="play:${players}" th:value="${play.getPlayerId()}" th:text="${play.getPlayerName()}">
            </select>
            <br>
            <div>
                选手1分数
                <input type="number" name="score1" th:value="${competition.getScore1()}">
            </div>
            <br>
            <div>
                选手2
                <select class="form-select form-select-lg mb-3" id="playerId_2" name="playerId_2" aria-label=".form-select-lg example">
                    <option th:value="${competition.getPlayerId_2().getPlayerId()}" th:text="${competition.getPlayerId_2().getPlayerName()}"></option>
                    <option th:each="play:${players}" th:value="${play.getPlayerId()}" th:text="${play.getPlayerName()}"></option>
                </select>
            </div>
            <br>
            <div>
                选手2分数
                <input type="number" name="score2" th:value="${competition.getScore2()}">
            </div>
            <br>
            <div>
                <button class="btn btn-info" style="width: 375px" type="submit" onClick="return confirm('确定修改?');">修改</button>
            </div>
    </form>
</div>
<script type="text/javascript">
    function test(){
        if ($("#playerId_1").val()==$("#playerId_2").val()){
            alert("选手不能相同！");
            return false;
        }
        if ($("#comName").val()==""){
            alert("比赛名称不能为空！");
            return false;
        }
    }
</script>
</body>
</html>